      <?php 
require_once 'models/models_thanhtoan.php';
$tt=new models_thanhtoan();      
    
      if (isset($_SESSION['cart'])) {
      	
  ?>
<div id="sanpham_right">
           	    <div id="title_right">
            		<p id="title_right_left"></p>
            		<div id="title_right_center">
            		  <p class="chu_title">GIỎ HÀNG CỦA BẠN</p>
            		</div>
           			<p id="title_right_right"></p>
             	</div>
                <div id="noidung_right">
                <!-- gio hang -->
                	<form name="update" action="" method="post" >
							<div id="con_giohang">
                            	<table width="100%" cellspacing="0" cellpadding="0" border="1" class="table_cart">
                                      <tr class="bg_cart_giohang" height="30px" >
                                        <th  class="table_cart">STT</th>
                                        <th class="table_cart">Tên hàng</th>
                                        <th  class="table_cart">Số lượng</th>
                                        <th  class="table_cart">Đơn giá</th>
                                        <th class="table_cart">Thành tiền</th>
                                        <th  class="table_cart">&nbsp;Xóa</th>
                                      </tr>
                                <?php
												$i = 1;
												$sumTotal = 0;
												foreach ($_SESSION['cart'] as $key => $value) {
												$mh=$tt->getmathang($key);
												
											?>

                                      <tr height="30px">
                                        <td class="table_cart" align="center">
										
                                            <?php echo $i; ?></td>
                                            
                                        <td class="table_cart" align="left"><?php echo $value['tenmh'];?></td>
                                        <td class="table_cart" align="center">
                                 <input name="cart[<?php echo $key; ?>]" type="text"  id="txtsoluong" value="<?php 
                                 if( $mh['SoLuong']>=$value['soluong'])
                                 {
                                 	echo $value['soluong'];
                                 }
                                 else 
                                 {
                                  echo $value['soluong']=$mh['SoLuong'];
                                 	
                                 }
                                 	?>" />
                                        </td>
                                        <td class="table_cart" align="center"><?php echo number_format($value['gia']);?></td>
                                        <td class="table_cart" align="center"><?php
													$total = $value['soluong'] * $value['gia'];
													echo number_format($total);
													?>
                                         </td>
                                        <td class="table_cart" align="center">
                                        <a href="index.php?mod=delcart&id=<?php echo $key?>">
                                        <img src="public/images/xoa_cart.png" height="15px"/>
                                        </a></td>
                                      </tr >
                                      <?php
										$sumTotal += $total;
										$i++;
										}
										?>
                                      <tr height="30px">
                                        <th class="table_cart" colspan="4" align="right" valign="top" scope="row">Tổng cộng</th>
                                        <th class="table_cart"  align="center" valign="top" align="center"><?php echo number_format($sumTotal); ?></th>
                                        <th class="table_cart" align="left" valign="top">VNĐ</th>
                                      </tr>
                                </table>
                                <?php }?>
                            </div>
                            <div id="nutxuly">
                                
                            	<input type="button" name="ok" value="" id="bt_tieptuc"
                                onclick="window.location.href='index.php'"/>
            					<input type="submit" name="ok" value="" id="bt_update"/>
                                <input type="button" name="thanhtoan" value="" id="bt_thanhtoan"
                                 onclick="window.location.href='index.php?mod=thanhtoan'"/>
                            </div>
					</form>
                    <!-- end -->
                           
                </div>
           </div>
    